package com.qst.controller.admin;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qst.entity.Goods;
import com.qst.service.admin.AdminGoodsService;
@Controller
@RequestMapping("/adminGoods")
public class AdminGoodsController extends BaseController{
    @Autowired
    private AdminGoodsService adminGoodsService;
    @RequestMapping("/selectGoods")
    public String selectGoods(Model model, Integer pageCur, String act) {
        return adminGoodsService.selectGoods(model, pageCur, act);
    }
    /**
     * add页面初始化
     */
    @RequestMapping("/toAddGoods")
    public String toAddGoods(Model model){
        model.addAttribute("goods", new Goods());
        return "admin/addGoods";
    }
    @RequestMapping("/toTop")
    public String toTop(Model model){
        model.addAttribute("goods", new Goods());
        return "admin/top";
    }
    @RequestMapping("/toLeft")
    public String toLeft(Model model){
        model.addAttribute("goods", new Goods());
        return "admin/left";
    }
    
    
    @RequestMapping("/toShopSearch")
    public String toShopSearch(Model model){
        model.addAttribute("goods", new Goods());
        return "admin/shop_search";
    }
    
    @RequestMapping("/toAddGoodsNew")
    public String toAddGoodsNew(Model model){
        model.addAttribute("goods", new Goods());
        return "admin/addGoods1";
    }
    
    /**
     * 添加与修改
     */
    @RequestMapping("/addGoods")
    public String addGoods(@ModelAttribute Goods goods, HttpServletRequest request, String updateAct){
        return adminGoodsService.addOrUpdateGoods(goods, request, updateAct);
    }
    /**
     * 查询一个名片
     */
    @RequestMapping("/selectAGoods")
    public String selectAGoods(Model model, Integer id, String act){
        return adminGoodsService.selectAGoods(model, id, act);
    }
    /**
     * 删除多个商品
     */
    @RequestMapping("/deleteGoods")
    public String deleteGoods(Integer ids[], Model model) {
        return adminGoodsService.deleteGoods(ids, model);
    }
    /**
     * 删除单个商品
     */
    @RequestMapping("/deleteAGoods")
    public String deleteAGoods(Integer id, Model model) {
        return adminGoodsService.deleteAGoods(id, model);
    }
}